
package View.GUI;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import Utils.TransparentButton;
import Utils.Utils;
import Utils.Timers.Timer;
import View.Game.GamePanel;

public class LittlePanelPlanetInfo extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private PlanetGUI planet_;
	private BufferedImage industryImage_;
	private BufferedImage ressourceImage_;
	private BufferedImage fleetMakerImage_;
	private BufferedImage background_;
	private JLabel popultionLabel_;
	private JLabel resourceLabel_;
	private JLabel fleetMakerLabel_;
	
	public LittlePanelPlanetInfo(int x, int y, PlanetGUI planet) {
		// TODO Auto-generated constructor stub
		setSize(100, 100);
		setLocation(x, y);
		setOpaque(false);
		setLayout(null);
		background_ = planet.getGamePanelController_().getMedia_().littlePlanetInfoBG_;
		URL url = LittlePanelPlanetInfo.class.getResource("/Image/Industry.png");
		industryImage_ = Utils.toBufferedImage((new ImageIcon(url)).getImage());
		url = LittlePanelPlanetInfo.class.getResource("/Image/Industry.png");
		ressourceImage_ = Utils.toBufferedImage((new ImageIcon(url)).getImage());
		url = LittlePanelPlanetInfo.class.getResource("/Image/Industry.png");
		fleetMakerImage_ = Utils.toBufferedImage((new ImageIcon(url)).getImage());
		planet_ = planet;
		popultionLabel_ = new JLabel(String.valueOf(planet_.getPlanet_().getPopulation_()));
		resourceLabel_ = new JLabel(String.valueOf(planet_.getPlanet_().getResources()));
		fleetMakerLabel_ = new JLabel(String.valueOf(planet_.getPlanet_().getFleet_().getNumShips()));
		
		popultionLabel_.setLocation(40, 10);
		resourceLabel_.setLocation(40, 40);
		fleetMakerLabel_.setLocation(40, 70);
		
		popultionLabel_.setSize(50, 20);
		resourceLabel_.setSize(50, 20);
		fleetMakerLabel_.setSize(50, 20);
		
		Font font = new Font("Verdana", Font.BOLD, 14);
		popultionLabel_.setForeground(Color.WHITE);
		resourceLabel_.setForeground(Color.WHITE);
		fleetMakerLabel_.setForeground(Color.WHITE);
		
		add(popultionLabel_);
		add(resourceLabel_);
		add(fleetMakerLabel_);
	}
	
	protected void paintComponent(Graphics g) {
		updateLabel();
		super.paintComponents(g);
		g.setColor( new Color( 240, 230, 140, 0) );
		g.fillRect( 0, 0, getWidth(), getHeight() );
		g.drawImage(background_, 0, 0, this);
		g.drawImage(industryImage_, 10, 10, 20, 20, null);
		g.drawImage(ressourceImage_, 10, 40, 20, 20, null);
		g.drawImage(fleetMakerImage_, 10, 70, 20, 20, null);
	}

	private void updateLabel() {
		// TODO Auto-generated method stub
		popultionLabel_.setText(String.valueOf(planet_.getPlanet_().getPopulation_()));
		resourceLabel_.setText(String.valueOf(planet_.getPlanet_().getResources()));
		fleetMakerLabel_.setText(String.valueOf(planet_.getPlanet_().getFleet_().getNumShips()));
	}
}
